import store from "@/store"

// 获取用户信息
export const getUserInfo = () => {
  console.log('@已获取用户信息');
  store.commit('user/modifyUserInfo', {
    cartTotal: 5,// 购物车数量
    userInfo: {
      nickName: '卡拉米',// 昵称
      coin: '15',// 鸡腿数
    }
  });
};

/**
 * 获取图片尺寸 —— 通过图片地址
 * @param url 
 * @returns 
 */
export const isSizeUseUrl = async (url) => {
  return await new Promise((resolve, reject) => {
    let img = new Image();
    img.onload = function () {
      resolve(img)
    };
    img.src = url;
  }).then((imgRes) => {
    console.log('@width', imgRes.width)
    console.log('@height', imgRes.height)
    return imgRes
  },
  );
}